<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--系统管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">

    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css" />
    <script src="__STATIC_URL__/static/js/jquery-2.1.4.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
{include file='public/header'/}
<section>
    <!------------------导航-------------------------->
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:&nbsp;</li>
                <li><a href="#">代理商管理</a></li>
                <li class="active" style="color: #02b87f;"> 代理商审核列表</li>
            </ul>
        </div>
        <div class="panel mgl15 mgr15" style="position: relative;">
            <div class="panel-heading addCharts" style="background:#ededed;">代理商审核列表</div>

            <div class="panel-body">
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>服务商名称</th>
                       

                        <th>手机</th>
                        <th>地址</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="agentlist" id="vo"}
                    <tr class="">
                        <td>{$vo['id']}</td>
                        <td>{$vo['name']}</td>


                        <td>{$vo['tel']}</td>
                        <td>{$vo['address']}</td>
                        <td>{$vo['check_status_ch']}</td>

                        <td>
                            <a href="{:url('agents/applyagentinfo',['id'=>$vo['id']])}" class="btn-link">查看</a>&nbsp;&nbsp;|&nbsp;
                            <a href="javascript:;" class="btn-link" onclick='show("{$vo['id']}")'>审核</a>&nbsp;&nbsp;
                        </td>
                    </tr>
                    {/volist}

                    </tbody>
                </table>
            </div>
            {$agentlist->render()}
        </div>
        {include file='public/footer'/}
    </div>

</section>

<!-- 是否重置该代理商审核密码（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">审核代理商</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

            </div>
            <div class="modal-body">

                <div class="form-group" style="    height: 33px;">
                    <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">审核结果</label>
                    <div class="col-sm-8">
                        <label class="radio-inline">
                            <input type="radio" name="appoval_status" id="status1" value="Y" checked onchange="tostatus(this,'Y')">通过
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="appoval_status" id="status2"  value="N" onchange="tostatus(this,'N')"> 拒绝
                        </label>
                    </div>

                </div>
                <div class="isstatus" >
                    <div class="form-group" style="height: 33px;">
                        <label for="sign_appid" class="col-sm-2 control-label" style="margin-top: 9px;">代理商appid</label>
                        <div class="col-sm-8">
                            <input  class="form-control" id="sign_appid" name="sign_appid" placeholder="请输入代理商appid" />

                        </div>

                    </div>

                    <div class="form-group" style="height: 33px;">
                        <label for="sign_key" class="col-sm-2 control-label" style="margin-top: 9px;">代理商key</label>
                        <div class="col-sm-10">
                            <input  class="form-control" id="sign_key" name="sign_key" placeholder="请输入代理商key" style="display: inline-block;width:80%"/>

                            <div class="val-file0  mgl15" style="display: inline-block;">
                                <div onclick="getrand('sign_key',32)">生成</div>
                            </div>
                        </div>

                    </div>
                </div>

                <div class="form-group" style="    height: 73px;">
                    <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">审核备注</label>
                    <div class="col-sm-8">
                        <textarea class="form-control" id="appoval_remark" name="appoval_remark" placeholder="请输入审核备注" rows="3"></textarea>

                    </div>

                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="btn-primary" data-id="" >确认</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

</body>
<script>
    function tostatus(obj,type){
        if(type=='Y'){
            $('.isstatus').attr("style",'display:block');
        }else{
            $('.isstatus').attr("style",'display:none');
        }

    }
    function show(id){
        $('#btn-primary').attr("data-id",id);
        $('#myModal').modal('show')
    }
    $("#btn-primary").click(function(){


        var agentid=$('#btn-primary').attr("data-id");

        var sign_appid=$('#sign_appid').val();
        var sign_key=$('#sign_key').val();

        var appoval_remark=$('#appoval_remark').val();
        var appoval_status=$("input[type='radio']:checked").val();
        if(appoval_status=='Y'){
            if (sign_appid == '') {
                alert('请填写代理商appid');
                return false;
            }
            if (sign_key == '') {
                alert('请填写代理商key');
                return false;
            }
        }

        $.ajax({
            url: "{:url('agents/appovalagent')}",
            type: 'POST',
            data: {
                agentid:agentid,
                appoval_status:appoval_status,
                appoval_remark:appoval_remark,
                sign_appid:sign_appid,
                sign_key:sign_key,
            },
            success: function (data) {
                console.log(data);
                $('#myModal').modal('hide')
            }
        })
    });


</script>
<script src="__STATIC_URL__/static/layer/layer.js"></script>
<script src="__STATIC_URL__/static/js/clipboard.min.js"></script>
<script>
    // $(function () {

    var clipboard =  new Clipboard('.copytext');

    clipboard.on('success', function (e) {
        layer.msg('复制成功');
    });

    clipboard.on('error', function (e) {
        layer.msg('复制失败');
    });
    // })
</script>
<script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>

<script>
    function getrand(type,nums) {

        $.ajax({
            url: "{:url('Agents/generate_rand')}",
            type: 'POST',
            cache: false,
            dataType: "json",
            data: {
                num: nums

            },
            success: function (data) {
                //console.log(data);
                $('#' + type).val(data);

            }

        });

    }
</script>
<script type="text/javascript">
    function agentform() {
        $("#agentform").submit();
    }
</script>
</html>
